﻿using System;

namespace Mbs.Messaging
{
    [Serializable]
    public class Topic<TMessage>:MarshalByRefObject
    {
        public string Name { get; private set; }
        public TMessage Message { get; private set; }

        internal Topic(string name, TMessage message)
        {
            Name = name;
            Message = message;
        }

        public override string ToString()
        {
            return Message.ToString();
        }

        public override object InitializeLifetimeService()
        {
            return null;
        }
    }

    public sealed class Topic
    {
        public static Topic<TMessage> Make<TMessage>(string name, TMessage message)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            return new Topic<TMessage>(name, message);
        }
    }
}
